<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>k8s | 撸码东东</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="整个教程基于  .&#x2F;kubernetes&#x2F;cluster&#x2F;centos 目录下面master和node的shell脚本 ​    1.二进制安装包说明  12345678910111213141516171819kubernetes.tar.gz：包含部署脚本、yml文件kubernetes-client-linux-amd64.tar.gz 包含kubectl命令kubernetes-serve">
<meta property="og:type" content="article">
<meta property="og:title" content="k8s">
<meta property="og:url" content="http://gwd0023.gitee.io/2020/01/05/k8s/index.html">
<meta property="og:site_name" content="撸码东东">
<meta property="og:description" content="整个教程基于  .&#x2F;kubernetes&#x2F;cluster&#x2F;centos 目录下面master和node的shell脚本 ​    1.二进制安装包说明  12345678910111213141516171819kubernetes.tar.gz：包含部署脚本、yml文件kubernetes-client-linux-amd64.tar.gz 包含kubectl命令kubernetes-serve">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://gwd0023.gitee.io/morning_xu_dong/2020/01/05/k8s/1.jpg">
<meta property="article:published_time" content="2020-01-05T10:42:14.000Z">
<meta property="article:modified_time" content="2020-01-05T10:43:13.552Z">
<meta property="article:author" content="John Doe">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://gwd0023.gitee.io/morning_xu_dong/2020/01/05/k8s/1.jpg">
  
    <link rel="alternate" href="/morning_xu_dong/atom.xml" title="撸码东东" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/morning_xu_dong/css/style.css">

<meta name="generator" content="Hexo 4.2.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/morning_xu_dong/" id="logo">撸码东东</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/morning_xu_dong/" id="subtitle">文学史上，我没有见过用阴谋除去了文学上的敌手，便成为文豪的人。所以，没有径取，只有踏实！</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/morning_xu_dong/">Home</a>
        
          <a class="main-nav-link" href="/morning_xu_dong/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/morning_xu_dong/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://gwd0023.gitee.io"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="create-k8s" class="article article-type-create" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/morning_xu_dong/2020/01/05/k8s/" class="article-date">
  <time datetime="2020-01-05T10:42:14.000Z" itemprop="datePublished">2020-01-05</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      k8s
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>整个教程基于  <strong>./kubernetes/cluster/centos</strong> 目录下面master和node的shell脚本</p>
<p>​    1.二进制安装包说明</p>
<p><img src="/morning_xu_dong/2020/01/05/k8s/1.jpg" alt="1"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">kubernetes.tar.gz：包含部署脚本、yml文件</span><br><span class="line">kubernetes-client-linux-amd64.tar.gz 包含kubectl命令</span><br><span class="line">kubernetes-server-linux-amd64.tar.gz 包含master节点上使用的所有服务命令</span><br><span class="line">kubernetes-node-linux-amd64.tar.gz 包含node节点上面所有的服务命令</span><br><span class="line">二进制文件上传到  master的&#x2F;srv  目录，并解压文件，</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[root@linux-node1 srv] ls -l</span><br><span class="line">total 510976</span><br><span class="line">drwxr-xr-x 9 root root       176 Feb 28 22:08 kubernetes</span><br><span class="line">-rw-r--r-- 1 root root  11980899 Mar 20 16:15 kubernetes-client-linux-amd64.tar.gz</span><br><span class="line">-rw-r--r-- 1 root root  91418745 Mar 20 16:18 kubernetes-node-linux-amd64.tar.gz</span><br><span class="line">-rw-r--r-- 1 root root 417885230 Mar 20 16:19 kubernetes-server-linux-amd64.tar.gz</span><br><span class="line">-rw-r--r-- 1 root root   1942234 Mar 20 16:15 kubernetes.tar.gz</span><br><span class="line">[root@linux-node1 srv]# pwd</span><br><span class="line">&#x2F;srv</span><br><span class="line"></span><br><span class="line">同时发送到node所有节点上</span><br><span class="line"> scp -r &#x2F;srv&#x2F;kubernetes 192.168.1.56:&#x2F;srv&#x2F;</span><br></pre></td></tr></table></figure>

<p>?    2、创建部署目录</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">每个虚拟机都创建</span><br><span class="line">mkdir -p &#x2F;opt&#x2F;kubernetes&#x2F;&#123;cfg,bin,ssl,log&#125;</span><br></pre></td></tr></table></figure>

<p>?    3、环境准备</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">操作系统：Centos7，Ubuntu</span><br><span class="line">关闭 firewalld服务</span><br><span class="line">    启动： systemctl start firewalld</span><br><span class="line">    关闭： systemctl stop firewalld</span><br><span class="line">    查看状态： systemctl status firewalld </span><br><span class="line">    开机禁用  ： systemctl disable firewalld</span><br><span class="line">    开机启用  ： systemctl enable firewalld</span><br><span class="line">关闭selinux</span><br><span class="line">	vi &#x2F;etc&#x2F;selinux&#x2F;config</span><br><span class="line">	将SELINUX&#x3D;enforcing改为SELINUX&#x3D;disabled </span><br><span class="line">	设置后需要重启才能生效</span><br><span class="line">设置hostname   ？？？？</span><br><span class="line">配置hosts文件域名解析</span><br><span class="line">修改为国内软件源</span><br><span class="line">把目录&#x2F;opt&#x2F;kubernetes&#x2F;bin&#x2F; 添加到$PATH 环境变量里面</span><br></pre></td></tr></table></figure>

<h1 id="master节点安装"><a href="#master节点安装" class="headerlink" title="master节点安装"></a>master节点安装</h1><h3 id="1-etcd安装"><a href="#1-etcd安装" class="headerlink" title="1  etcd安装"></a>1  etcd安装</h3><p><strong>在master节点：</strong></p>
<p>安装etcd服务</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install -y etcd</span><br></pre></td></tr></table></figure>

<p>修改配置文件：<strong>ip地址修改成master地址</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">[root@linux-node1 srv]# vim /etc/etcd/etcd.conf </span><br><span class="line"></span><br><span class="line">[root@linux-node1 srv]# cat /etc/etcd/etcd.conf | grep -Ev "(^#|^$)"</span><br><span class="line">ETCD_DATA_DIR="/var/lib/etcd/default.etcd"</span><br><span class="line">ETCD_LISTEN_CLIENT_URLS="http://192.168.1.56:2379"</span><br><span class="line">ETCD_NAME="default"</span><br><span class="line">ETCD_ADVERTISE_CLIENT_URLS="http://192.168.1.56:2379"</span><br></pre></td></tr></table></figure>

<p>启动服务</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">systemctl start etcd</span><br><span class="line">systemctl enable etcd</span><br><span class="line">systemctl status etcd</span><br></pre></td></tr></table></figure>



<h3 id="2-kube-apiserver服務安裝"><a href="#2-kube-apiserver服務安裝" class="headerlink" title="2 kube-apiserver服務安裝"></a>2 kube-apiserver服務安裝</h3><p>在master节点上操作：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br></pre></td><td class="code"><pre><span class="line">1、复制命令：</span><br><span class="line">[root@linux-node1 srv]# cd /srv/kubernetes/server/bin/</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 一次性都复制了 省的一个一个复制</span></span><br><span class="line">[root@linux-node1 bin]# cp -rp kube-apiserver kubectl  kubelet  kube-proxy kube-scheduler kube-controller-manager /opt/kubernetes/bin/</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">2 执行官方提供的shell节本，安装kube-apiserver安装</span><br><span class="line">[root@linux-node1 bin]# cd /srv/kubernetes/cluster/centos/master/scripts/</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> MASTER_ADDRESS 为master 的ip地址</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> ETCD_SERVERS  etcd的服务地址 eg： http://192.168.1.56:2379</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> SERVICE_CLUSTER_IP_RANGE   SERVICE的网段设置（service是k8s中的概念） 就写10.1.0.0/24</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> 详情看shell脚本</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> ./apiserver.sh  MASTER_ADDRESS ETCD_SERVERS SERVICE_CLUSTER_IP_RANGE</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> 所以命令如下：</span></span><br><span class="line"><span class="meta">[root]#</span><span class="bash"> bash -x apiserver.sh  192.168.1.56  http://192.168.1.56:2379 10.1.0.0/24 </span></span><br><span class="line"></span><br><span class="line">3 修改一下shell脚本生成的配置文件，去掉有关ssl的设置</span><br><span class="line">[root@linux-node1 cfg]# vim /opt/kubernetes/cfg/kube-apiserver</span><br><span class="line"> 11 # --etcd-cafile="": SSL Certificate Authority file used to secure etcd communication.</span><br><span class="line"> 12 #KUBE_ETCD_CAFILE="--etcd-cafile=/srv/kubernetes/etcd/ca.pem"</span><br><span class="line"> 13 </span><br><span class="line"> 14 # --etcd-certfile="": SSL certification file used to secure etcd communication.</span><br><span class="line"> 15 #KUBE_ETCD_CERTFILE="--etcd-certfile=/srv/kubernetes/etcd/client.pem"</span><br><span class="line"> 16 </span><br><span class="line"> 17 # --etcd-keyfile="": key file used to secure etcd communication.</span><br><span class="line"> 18 #KUBE_ETCD_KEYFILE="--etcd-keyfile=/srv/kubernetes/etcd/client-key.pem"</span><br><span class="line"></span><br><span class="line">.....................................</span><br><span class="line"> 50 # --client-ca-file="": If set, any request presenting a client certificate signed</span><br><span class="line"> 51 # by one of the authorities in the client-ca-file is authenticated with an identity</span><br><span class="line"> 52 # corresponding to the CommonName of the client certificate.</span><br><span class="line"> 53 #KUBE_API_CLIENT_CA_FILE="--client-ca-file=/srv/kubernetes/ca.crt"</span><br><span class="line"> 54 </span><br><span class="line"> 55 # --tls-cert-file="": File containing x509 Certificate for HTTPS.  (CA cert, if any,</span><br><span class="line"> 56 # concatenated after server cert). If HTTPS serving is enabled, and --tls-cert-file</span><br><span class="line"> 57 # and --tls-private-key-file are not provided, a self-signed certificate and key are</span><br><span class="line"> 58 # generated for the public address and saved to /var/run/kubernetes.</span><br><span class="line"> 59 #KUBE_API_TLS_CERT_FILE="--tls-cert-file=/srv/kubernetes/server.cert"</span><br><span class="line"> 60 </span><br><span class="line"> 61 # --tls-private-key-file="": File containing x509 private key matching --tls-cert-file.</span><br><span class="line"> 62 #KUBE_API_TLS_PRIVATE_KEY_FILE="--tls-private-key-file=/srv/kubernetes/server.key"                                       </span><br><span class="line">                                                                                          </span><br><span class="line"></span><br><span class="line">4 修改服务启动文件，去掉上面注掉的6个变量</span><br><span class="line">[root@linux-node1 scripts]# vim /usr/lib/systemd/system/kube-apiserver.service</span><br><span class="line">[root@linux-node1 scripts]# </span><br><span class="line">[root@linux-node1 scripts]# cat /usr/lib/systemd/system/kube-apiserver.service</span><br><span class="line">[Unit]</span><br><span class="line">Description=Kubernetes API Server</span><br><span class="line">Documentation=https://github.com/kubernetes/kubernetes</span><br><span class="line"></span><br><span class="line">[Service]</span><br><span class="line">EnvironmentFile=-/opt/kubernetes/cfg/kube-apiserver</span><br><span class="line">ExecStart=/opt/kubernetes/bin/kube-apiserver    $&#123;KUBE_LOGTOSTDERR&#125;         \</span><br><span class="line">                        $&#123;KUBE_LOG_LEVEL&#125;           \</span><br><span class="line">                        $&#123;KUBE_ETCD_SERVERS&#125;        \</span><br><span class="line">                        $&#123;KUBE_API_ADDRESS&#125;         \</span><br><span class="line">                        $&#123;KUBE_API_PORT&#125;            \</span><br><span class="line">                        $&#123;NODE_PORT&#125;                \</span><br><span class="line">                        $&#123;KUBE_ADVERTISE_ADDR&#125;      \</span><br><span class="line">                        $&#123;KUBE_ALLOW_PRIV&#125;          \</span><br><span class="line">                        $&#123;KUBE_SERVICE_ADDRESSES&#125;   \</span><br><span class="line">                        $&#123;KUBE_ADMISSION_CONTROL&#125;   \</span><br><span class="line">Restart=on-failure</span><br><span class="line"></span><br><span class="line">[Install]</span><br><span class="line">WantedBy=multi-user.target</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">5重启服务</span><br><span class="line">[root@linux-node1 scripts]# systemctl daemon-reload </span><br><span class="line">[root@linux-node1 scripts]# systemctl restart kube-apiserver.service </span><br><span class="line">[root@linux-node1 scripts]# systemctl status kube-apiserver.service</span><br></pre></td></tr></table></figure>

<h3 id="3-kube-scheduler-服務安裝"><a href="#3-kube-scheduler-服務安裝" class="headerlink" title="3 kube-scheduler-服務安裝"></a>3 kube-scheduler-服務安裝</h3><h3 id="4-kube-controller-服務安裝"><a href="#4-kube-controller-服務安裝" class="headerlink" title="4 kube-controller-服務安裝"></a>4 kube-controller-服務安裝</h3><h1 id="node节点安装"><a href="#node节点安装" class="headerlink" title="node节点安装"></a>node节点安装</h1><h3 id="1、flannel服务安装"><a href="#1、flannel服务安装" class="headerlink" title="1、flannel服务安装"></a>1、flannel服务安装</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><span class="line">1、安装docker服务</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">下载地址：https:&#x2F;&#x2F;github.com&#x2F;coreos&#x2F;flannel&#x2F;releases</span><br><span class="line">2、flannel命令准备</span><br><span class="line"># flanneld命令</span><br><span class="line">[root@linux-node1 srv]# cp flanneld mk-docker-opts.sh  &#x2F;opt&#x2F;kubernetes&#x2F;bin&#x2F;</span><br><span class="line"># etcdctl命令 从master复制&#x2F;opt&#x2F;kubernetes&#x2F;bin&#x2F;</span><br><span class="line">scp 192.168.1.56:&#x2F;usr&#x2F;bin&#x2F;etcdctl &#x2F;opt&#x2F;kubernetes&#x2F;bin&#x2F;</span><br><span class="line"></span><br><span class="line">3 执行shell脚本</span><br><span class="line">[root@linux-node1 srv]# cd &#x2F;srv&#x2F;kubernetes&#x2F;cluster&#x2F;centos&#x2F;node&#x2F;scripts&#x2F;</span><br><span class="line"></span><br><span class="line"># .&#x2F;flannel.sh  ETCD_SERVERS FLANNEL_NET</span><br><span class="line"># ETCD_SERVERS :etcd 的服务器地址</span><br><span class="line"># FLANNEL_NET flannel的网段 </span><br><span class="line"># 所以命令如下 ？？？？？</span><br><span class="line">[root@linux-node1 scripts]# bash -x flannel.sh  http:&#x2F;&#x2F;192.168.1.56:2379 10.2.0.0&#x2F;16</span><br><span class="line"></span><br><span class="line">4 修改配置文件 ，去掉ssl配置</span><br><span class="line">[root@linux-node1 scripts]# vim &#x2F;opt&#x2F;kubernetes&#x2F;cfg&#x2F;flannel</span><br><span class="line"></span><br><span class="line">[root@linux-node1 scripts]# cat &#x2F;opt&#x2F;kubernetes&#x2F;cfg&#x2F;flannel</span><br><span class="line">FLANNEL_ETCD&#x3D;&quot;-etcd-endpoints&#x3D;http:&#x2F;&#x2F;192.168.56.11:2379&quot;</span><br><span class="line">FLANNEL_ETCD_KEY&#x3D;&quot;-etcd-prefix&#x3D;&#x2F;coreos.com&#x2F;network&quot;</span><br><span class="line">#FLANNEL_ETCD_CAFILE&#x3D;&quot;--etcd-cafile&#x3D;&#x2F;srv&#x2F;kubernetes&#x2F;etcd&#x2F;ca.pem&quot;</span><br><span class="line">#FLANNEL_ETCD_CERTFILE&#x3D;&quot;--etcd-certfile&#x3D;&#x2F;srv&#x2F;kubernetes&#x2F;etcd&#x2F;client.pem&quot;</span><br><span class="line">#FLANNEL_ETCD_KEYFILE&#x3D;&quot;--etcd-keyfile&#x3D;&#x2F;srv&#x2F;kubernetes&#x2F;etcd&#x2F;client-key.pem&quot;</span><br><span class="line"></span><br><span class="line">#############################</span><br><span class="line"></span><br><span class="line">############################3</span><br><span class="line"></span><br><span class="line">5、重启flannel服务</span><br><span class="line">[root@linux-node1 scripts]# systemctl daemon-reload </span><br><span class="line">[root@linux-node1 scripts]# systemctl restart flannel.service </span><br><span class="line"></span><br><span class="line">6 修改docker启动配置文件，使用flannel设置的网络参数</span><br><span class="line">[root@linux-node1 ~]# vim &#x2F;usr&#x2F;lib&#x2F;systemd&#x2F;system&#x2F;docker.service</span><br><span class="line">[Unit] #在Unit下面修改After和增加Requires</span><br><span class="line">After&#x3D;network-online.target firewalld.service flannel.service</span><br><span class="line">Wants&#x3D;network-online.target</span><br><span class="line">Requires&#x3D;flannel.service</span><br><span class="line"></span><br><span class="line">[Service] #增加EnvironmentFile&#x3D;-&#x2F;run&#x2F;flannel&#x2F;docker</span><br><span class="line">Type&#x3D;notify</span><br><span class="line">EnvironmentFile&#x3D;-&#x2F;run&#x2F;flannel&#x2F;docker</span><br><span class="line">ExecStart&#x3D;&#x2F;usr&#x2F;bin&#x2F;dockerd $DOCKER_OPTS</span><br><span class="line"></span><br><span class="line">重启Docker</span><br><span class="line">[root@linux-node1 ~]# systemctl daemon-reload</span><br><span class="line">[root@linux-node1 ~]# systemctl restart docker</span><br></pre></td></tr></table></figure>

<h3 id="2-kubelet"><a href="#2-kubelet" class="headerlink" title="2 kubelet"></a>2 kubelet</h3><h3 id="3-kube-proxy"><a href="#3-kube-proxy" class="headerlink" title="3 kube-proxy"></a>3 kube-proxy</h3>
      
    </div>
    <footer class="article-footer">
      <a data-url="http://gwd0023.gitee.io/2020/01/05/k8s/" data-id="ck50w1tji000040tu39oq2yqx" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/morning_xu_dong/2020/03/15/test/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          test
        
      </div>
    </a>
  
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/morning_xu_dong/archives/2020/03/">March 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/morning_xu_dong/archives/2020/01/">January 2020</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/morning_xu_dong/2020/03/15/666/">666</a>
          </li>
        
          <li>
            <a href="/morning_xu_dong/2020/03/15/555/">555</a>
          </li>
        
          <li>
            <a href="/morning_xu_dong/2020/03/15/test/">test</a>
          </li>
        
          <li>
            <a href="/morning_xu_dong/2020/01/05/k8s/">k8s</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 面向阳光<br>

    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/morning_xu_dong/" class="mobile-nav-link">Home</a>
  
    <a href="/morning_xu_dong/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/morning_xu_dong/fancybox/jquery.fancybox.css">

  
<script src="/morning_xu_dong/fancybox/jquery.fancybox.pack.js"></script>




<script src="/morning_xu_dong/js/script.js"></script>




  </div>
</body>
</html>